package com.jetinno.net;

import android.text.TextUtils;

import com.jetinno.bean.SerialBean;

/**
 * Description :
 * Author :mhwang
 * Date : 2017/8/22
 * Version : V1.0
 */

public class ServerAddress extends SerialBean {
    private int tableId;
    private String address;
    private int port;

    public ServerAddress(String address, int port) {
        this.address = address;
        this.port = port;
    }

    @Override
    public String toString() {
        return "ServerAddress{" +
                "tableId=" + tableId +
                ", address='" + address + '\'' +
                ", port=" + port +
                '}';
    }

    public ServerAddress() {
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getTableId() {
        return tableId;
    }

    public void setTableId(int tableId) {
        this.tableId = tableId;
    }

    ///只要IP地址和端口号一致，则相同
    public boolean equals(ServerAddress address2) {
        ServerAddress address1 = this;
        if (address2 == null) {
            return false;
        }
        String addressText1 = String.format("%s:%s", address1.getAddress(), address1.getPort());
        String addressText2 = String.format("%s:%s", address2.getAddress(), address2.getPort());
        return TextUtils.equals(addressText1, addressText2);
    }
}
